@page
@{ Layout = "_Layout"; }

@section Styles{
    <style>
        .el-rate{ line-height:42px; }
    </style>
}
<el-card>
    <div slot="header" class="clearfix">
        <span>{{ id>0 ? "修改题目" : "新增题目"}}</span>
        <el-button style="float: right;padding:3px 0;" type="text" v-on:click="utils.closeLayerSelf"><i class="el-icon-close"></i></el-button>
    </div>
    <el-scrollbar class="scrollbar" :style="{ height: ($(window).innerHeight()-180) + 'px' }">
        <div style="margin-right:18px;">
            <el-form :model="form" ref="form" v-if="form" :size="euiSize" label-width="100px">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="题型" prop="txId" :rules="{ required: true, message: '请选择题型' }">
                            <el-select v-model="form.txId" placeholder="请选择题型" v-on:change="txChange">
                                <el-option v-for="tx in txList"
                                           :key="tx.id"
                                           :label="tx.name"
                                           :value="tx.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="分类" prop="treeId" :rules="{ required: true, message: '请选择分类' }">
                            <el-cascader ref="tmTree" style="width:100%;"
                                         v-model="form.treeId"
                                         :options="tmTreeData"
                                         :props="{ emitPath:false,checkStrictly: true,expandTrigger:'hover' }"
                                         placeholder="请选择分类"
                                         :show-all-levels="false">
                            </el-cascader>
                        </el-form-item>
                        <el-form-item label="难度" prop="nandu" :rules="{ required: true, message: '请选择难度' }">
                            <el-rate v-model="form.nandu"></el-rate>
                        </el-form-item>
                        <el-form-item label="知识点" prop="zhishidian" :rules="{ required: true, message: '请输入知识点' }">
                            <el-input v-model.trim="form.zhishidian" placeholder="请输入知识点"></el-input>
                        </el-form-item>
                        <el-form-item label="分数" prop="score" :rules="{ required: true, message: '请输入分数' }">
                            <el-input-number :disabled="curBaseTx==='Zuheti'" :precision="2" :step="1" v-model.trim="form.score" :min="1" :max="100" placeholder="请输入分数"></el-input-number>
                            <div class="tips" v-if="curBaseTx==='Zuheti'">组合题的总分是所有子题分数的总和，不能手动编辑。</div>
                        </el-form-item>
                        <el-form-item label="解析" prop="jiexi">
                            <el-input ref="jiexi" type="textarea" :autosize="{ minRows: 3}" v-model="form.jiexi"></el-input>
                            <el-link type="primary" icon="el-icon-document" v-on:click="btnOpenEditClick('jiexi','form')">ueditor</el-link>
                            <el-divider direction="vertical"></el-divider>
                            <el-link type="primary" icon="el-icon-document" v-on:click="btnOpenEditPlusClick('jiexi','form')">ueditorPlus</el-link>
                        </el-form-item>
                        <el-form-item label="状态" prop="locked">
                            <el-select v-model="form.locked">
                                <el-option label="启用" :value="false"></el-option>
                                <el-option label="停用" :value="true"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="题目内容" prop="title" :rules="{ required: true, message: '请输入题目内容' }">
                            <el-input ref="title" type="textarea" :autosize="{ minRows: 3}" v-model="form.title"></el-input>
                            <el-link type="primary" icon="el-icon-document" v-on:click="btnOpenEditClick('title','form')">ueditor</el-link>
                            <el-divider direction="vertical"></el-divider>
                            <el-link type="primary" icon="el-icon-document" v-on:click="btnOpenEditPlusClick('title','form')">ueditorPlus</el-link>
                            <div class="tips">填空占位符“___”，三个英文全角下划线。</div>
                        </el-form-item>
                        <template v-if="curBaseTx">
                            <template v-if="curBaseTx==='Danxuanti'">
                                <el-form-item>
                                    候选项
                                </el-form-item>
                                <el-form-item  v-for="(optionvalue,index) in options">
                                    <el-input v-model.trim="options[index]">
                                        <el-radio slot="prepend" v-model="optionsValue" :label="optionsABC[index]"></el-radio>
                                        <el-tooltip slot="append" content="富文本编辑" placement="left">
                                            <el-button icon="el-icon-document" v-on:click="btnOpenEditClick(index,'options')"></el-button>
                                        </el-tooltip>
                                    </el-input>
                                </el-form-item>
                                <el-form-item>
                                    <el-button plain icon="el-icon-plus" v-on:click="btnAddOptions">候选项</el-button>
                                    <el-button v-if="btnMinusOptionsShow" plain icon="el-icon-minus" v-on:click="btnMinusOptions">候选项</el-button>
                                </el-form-item>
                            </template>
                            <template v-else-if="curBaseTx==='Duoxuanti'">
                                <el-form-item>
                                    候选项
                                </el-form-item>
                                <el-form-item v-for="(optionvalue,index) in options">
                                    <el-input v-model.trim="options[index]">
                                        <el-checkbox slot="prepend" :true-label="optionsABC[index]" false-label="" v-model="optionsValue[index]" :label="optionsABC[index]"></el-checkbox>
                                        <el-tooltip slot="append" content="富文本编辑" placement="left">
                                            <el-button icon="el-icon-document" v-on:click="btnOpenEditClick(index,'options')"></el-button>
                                        </el-tooltip>
                                    </el-input>
                                </el-form-item>
                                <el-form-item>
                                    <el-button plain icon="el-icon-plus" v-on:click="btnAddOptions">候选项</el-button>
                                    <el-button v-if="btnMinusOptionsShow" plain icon="el-icon-minus" v-on:click="btnMinusOptions">候选项</el-button>
                                </el-form-item>
                            </template>
                            <template v-else-if="curBaseTx==='Panduanti'">
                                <el-form-item>
                                    候选项
                                </el-form-item>
                                <el-form-item v-for="(optionvalue,index) in options">
                                    <el-input v-model="options[index]">
                                        <el-radio slot="prepend" v-model="optionsValue" :label="optionsABC[index]"></el-radio>
                                    </el-input>
                                </el-form-item>
                            </template>
                            <template v-else-if="curBaseTx==='Zuheti'">
                                <el-form-item>
                                    <span style="font-weight:bolder;">组合题子题</span>
                                </el-form-item>
                                <el-form-item>
                                    <el-table border :data="tableTmSmallList" empty-text="请添加组合题子题" size="small"
                                              style="width: 100%" :row-key="Math.random()">
                                        <el-table-column prop="title" label="题目">
                                        </el-table-column>
                                        <el-table-column label="题型">
                                            <template slot-scope="scope">
                                                {{ txFormatterName(scope.row.txId) }}
                                            </template>
                                        </el-table-column>
                                        <el-table-column prop="score" label="分数">
                                        </el-table-column>
                                        <el-table-column width="100" align="right">
                                            <template slot-scope="scope">
                                                <el-dropdown :show-timeout="0" placement="left">
                                                    <el-button icon="el-icon-arrow-left" size="mini" v-on:click.stop="return false">
                                                        操作
                                                    </el-button>
                                                    <el-dropdown-menu slot="dropdown">
                                                        <el-dropdown-item icon="el-icon-edit" v-on:click.native="btnSmallEdit(scope.row.id,scope.row.guid)">修改</el-dropdown-item>
                                                        <el-dropdown-item icon="el-icon-delete" v-on:click.native="btnSmallDelete(scope.row.id,scope.row.guid)" style="color:red;" divided>删除</el-dropdown-item>
                                                    </el-dropdown-menu>
                                                </el-dropdown>
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-form-item>
                                <el-form-item>
                                    <el-button plain icon="el-icon-plus" v-on:click="btnSmallEdit(0,'')">新增子题</el-button>
                                </el-form-item>
                            </template>
                            <template v-else>
                                <el-form-item label="答案" prop="answer">
                                    <el-input ref="answer" type="textarea" :autosize="{ minRows: 3}" v-model.trim="form.answer"></el-input>
                                    <el-link type="primary" icon="el-icon-document" v-on:click="btnOpenEditClick('answer','form')">富文本编辑</el-link>
                                    <div class="tips">主观题答案用(，,；;)等分隔，自动判分时会进行标准答案匹配。</div>
                                </el-form-item>
                            </template>
                        </template>
                    </el-col>
                </el-row>
            </el-form>
        </div>
    </el-scrollbar>
</el-card>
<el-row align="center" style="margin-top:18px;">
    <el-col :span="24" align="center">
        <el-button icon="el-icon-check" type="primary" v-on:click="btnSubmitClick" :size="euiSize">确 定</el-button>
        <el-button icon="el-icon-close" v-on:click="utils.closeLayerSelf" :size="euiSize">取 消</el-button>
    </el-col>
</el-row>
@section Scripts{
<script src="/sitefiles/assets/js/admin/exam/examTmEdit.js" type="text/javascript"></script>
 }
